import React from "react";
import Chart from "echarts-for-react";
import PublicService from '../../../services/PublicService';
import request from '../../../utils/request';
import echarts from 'echarts'

class StaTu extends React.Component {

    constructor(props) {
        super(props)
        this.state={
            disList:{}
        }

    }



    setOption  = () => {
        let data = this.state.disList
        return {
        
            //title: {
            //    text: '报警次数'
            //},
            tooltip: {
                trigger: 'axis',
                //formatter: "{b} <br> 合格率: {c}%"
            },
            legend: {
                data: this.props.data?this.props.data.nameList:[]
            },
            grid: {
                left: '3%',
                right: '4%',
                bottom: '3%',
                containLabel: true
            },
            dataZoom: [{
                type: 'slider',
                xAxisIndex: 0,
                filterMode: 'empty',
                start: 0,
                end: 100
            }
                // , {
                //     type: 'slider',
                //     yAxisIndex: 0,
                //     filterMode: 'empty',
                //     start: 0,
                //     end: 100
                // }
                , {
                type: 'inside',
                xAxisIndex: 0,
                filterMode: 'empty',
                start: 0,
                end: 100
            }, {
                type: 'inside',
                yAxisIndex: 0,
                filterMode: 'empty',
                start: 0,
                end: 100
            }],
            toolbox: {
                feature: {
                    saveAsImage: {}
                }
            },
            xAxis: {
                type: 'category',
                name: '日期',
                boundaryGap: false,
                data:this.props.data?this.props.data.timeList:[]
            },
            yAxis: {
                type: 'value',
                name: '数量',
            },
            series: this.props.data?this.props.data.resultList:[]
        };

        

    }

    render() {
      
        return (

                 <Chart option={this.setOption()} notMerge lazyUpdate style={{height:"50vh"}}
                 echartsInstance={this.save}
                 />
          

         
           
          );
    }
   
}

export default StaTu;
